﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArrayCollections
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] stringArray = new string[]
                {
                    "Башот",
                    "Ашот-сан",
                    "Ваншот"
                };

            Array.Sort(stringArray);
            //Array.Sort(stringArray, new MyCustomStringComparer());

            foreach (var name in stringArray)
            {
                Console.WriteLine(name);
            }




            //var stringArray2 = stringArray.Reverse().ToArray();
            //Console.WriteLine(stringArray2[2]);

            //Human h1 = new Human()
            //{
            //    FirstName = "Carl",
            //    LastName = "Father",
            //    Age = 20
            //};

            //Human h2 = new Human()
            //{
            //    FirstName = "Vasya",
            //    LastName = "Pupkin",
            //    Age = 12
            //};

            //Human[] humanArray = new Human[2];

            //humanArray[0] = h1;
            //humanArray[1] = h2;

            //Array.Sort(humanArray);

            //foreach (var human in humanArray)
            //{
            //    Console.WriteLine(human);
            //}


        }
    }

    class Human : IComparable<Human>
    {
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public int Age { get; set; }

        public int CompareTo(Human other)
        {
            if (Age < other.Age)
            {
                return -1;
            }
            else if (Age == other.Age)
            {
                return 0;
            }
            else
                return 1;
        }

        public override string ToString()
        {
            return FirstName + " " + LastName + " " + Age;
        }
    }

    class MyCustomStringComparer : IComparer<string>
    {
        public int Compare(string x, string y)
        {
            if (x.Length < y.Length)
                return -1;
            else if (x.Length == y.Length)
                return 0;
            return 1;
        }
    }
}
